import React, { useState } from 'react'

function Father() {
    const [count, setCount] = useState(true)
    function fun() {
        setCount(!count)
    }
    return {
        count,
        fun
    }
}
//类似组件传参

function Son() {
    const { count, fun } = Father()
    return (
        <div>
            {count && <div>你好</div>}
            <button onClick={fun}>点击</button>
        </div>
    )
}

export default Son
